﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;
using ZlenStack.DeviceCenter.Domain.Repositories;
using ZlenStack.DeviceCenter.Domain.Services.Projects;

namespace ZlenStack.DeviceCenter.Domain
{
    public static class DependencyRegistrar
    {
        public static IServiceCollection AddDomainLayer(this IServiceCollection services)
        {
            services.AddTransient<IProjectDomainService, ProjectDomainService>();

            var dataSeedProviders = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.ExportedTypes).Where(t => t.IsAssignableTo(typeof(IDataSeedProvider)) && t.IsClass);
            dataSeedProviders.ToList().ForEach(t => services.AddTransient(typeof(IDataSeedProvider), t));
            //services.AddTransient<IDataSeedProvider, ProductDataSeedProvider>();
            //services.AddTransient<IDataSeedProvider, ProjectDataSeedProvider>();

            return services;
        }
    }
}
